"""
34 IMAGE
35 TEXT
36 UNIQUEIDENTIFIER
40 Date
48 TINYINT
52 SMALLINT
56 INT
58 SMALLDATETIME
59 REAL
60 MONEY
61 DATETIME
62 FLOAT
98 SQL_VARIANT
99 NTEXT
104 BIT
106 DECIMAL
108 NUMERIC
122 SMALLMONEY
127 BIGINT
165 VARBINARY
167 VARCHAR
173 BINARY
175 CHAR
"""


import pymssql
conn = pymssql.connect(host='192.168.10.242',user='shuju',password='sundrun.BI2020',database='dotnet_erp25',charset='utf8')
#conn = pymssql.connect(host='192.168.10.247',user='sa',password='sundrun@xxh123',database='dotnet_erp352SP3',charset='utf8')
#conn = pymssql.connect(host='192.168.10.247',user='sa',password='sundrun@xxh123',database='donet_erp352SP3',charset='utf8')
def debug(sql):
    print(sql)
    return sql
 
#查看连接是否成功
cursor = conn.cursor()
cursor.execute(debug("  select id,name from sysobjects  where xtype = 'U'    "))
tableList = []
rs = cursor.fetchall()
for row in rs:
    tableList.append(row)


for table in tableList:
    tableId = table[0]
    tableName = table[1]
    cursor.execute("select name from syscolumns where id = {} and xtype in (60,106,108)".format(table[0]))
    for row in cursor.fetchall():
        columnName = row[0]
        sql = '''
            select [{}] from {} where [{}]  = 71113.45
        '''.format(columnName,tableName,columnName)
     
        cursor.execute(sql)
        results = cursor.fetchall()
      
        if len(results) == 0:
            #print(tableName,"continue")
            continue
        print(tableName,columnName)

print("结束")






